{% extends "that_person_center/base.html" %}


{% block page_link %}
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/index.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/common.css">
    <script type="text/javascript" src="../../static/personal_center/js/index.js"></script>
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }
        .log_class {
            width: 110px;height: 40px;text-align: center;line-height: 40px;display: inline-block;vertical-align: top;cursor: pointer;
        }
        .log_class_active {
            border-bottom: #00a0e9 solid 1px;color: #00a0e9;
        }
        .file {
            position: relative;display: inline-block;background: #D0EEFF;border: 1px solid #99D3F5;border-radius: 4px;padding: 4px 12px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;
        }
        .file input {
            position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;
        }
        .file:hover {
            background: #AADFFD;border-color: #78C3F3;color: #004974;text-decoration: none;
        }
        .button_for_control {
            width: 85px;height: 30px;border: 1px solid #99D3F5;background: #D0EEFF;border-radius: 4px;letter-spacing: 0;line-height: 30px;color: #089bab;margin-top: 10px;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div style="width: 100%;height: 100%;">
        <div style="width: 100%;height: 40px;border-bottom: #DFDFDF solid 1px;background: white;">
            <div style="float: left;vertical-align: top;width: 30%;text-align: left;">
                <div id="my_log_top" class="log_class log_class_active" onclick="chance_tag(this.id)">我的日志</div>
                <div id="company_log_top" class="log_class" onclick="chance_tag(this.id)">科室日志</div>
            </div>

            <div style="float: right;vertical-align: top;width: 50%;text-align: right;padding-right: 15px;">
                <input type="text" style="width: 250px;height: 30px;margin-top: 5px;border: #00a0e9 solid 1px;border-bottom-left-radius: 3px;border-top-left-radius: 3px;outline: none;padding-left: 1px;">
                <button style="width: 80px;height: 30px;margin-top: 5px;border-top-right-radius: 3px;border-bottom-right-radius: 3px;border: #00a0e9 solid 1px;border-left: none;background: #00a0e9;color: white;letter-spacing: 5px;margin-left: -4.5px;cursor: pointer;">搜索</button>
            </div>
        </div>

        <div style="width: 100%;height: 40px;background: white;">
            <div style="float: left;vertical-align: top;width: 30%;text-align: left;padding-left: 10px;">
                <button id="" onmousemove="page_zhanshi()" onmouseout="page_yincang()" style="width: 100px;height: 30px;line-height: 27px;border: #1E90FF solid 1px;background: #1E90FF;color: white;margin-top: 5px;">
                    操作
                </button>
            </div>

            <div id="page_one" onmousemove="page_zhanshi()" onmouseout="page_yincang()" style="z-index: 1000; position: absolute; width: 100px; height: auto;left: 14.6%; top: 120px;background: #FFFFFF; box-shadow: rgb(204 204 204) 2px 2px 10px;padding: 5px;display: none;">
                <a href="javascript:;" class="file" style="vertical-align: top;margin-top: 5px;float: left;">
                    上传文件
                    <input type="file" name="party_main_body" id="party_main_body" onchange="upload_excel()">
                </a>

                <button type="button" class="button_for_control">
                    <a href="../../static/that_person_center/excel_template/工作日志.xlsx">日志模板</a>
                </button>
            </div>

            <div style="width: 30%;height: 40px;float: right;padding-right: 15px;text-align: right;vertical-align: top;">
                <button style="width: 80px;height: 30px;margin-top: 5px;border: #00a0e9 solid 1px;background: #00a0e9;color: white;letter-spacing: 5px;text-align: center;border-radius: 3px;">添加</button>
            </div>
        </div>

        <div id="my_log" style="width: 100%;height: 90.5%;background: white;overflow: auto;">
            <div class="right-box" style="width: 100%;height: 100%;margin-top: 0;">
                <div style="height: 100%;width: 100%;overflow: auto;border-bottom: #cccccc solid 1px;background-color: white;">
                    <section class="grid-main" style="height: 100%;">
                        <table id="main_table"></table>
                    </section>
                </div>
            </div>
        </div>
    </div>
{% endblock %}


{% block script %}
    <script>
        window.onload = function () {
            document.getElementById("loading").style.display = "none";
            document.getElementById("LogManagement").className = "add_class";
            document.getElementById("my-center").className = "add-nav-active";
        };

        function chance_tag(item_id) {
            if (item_id === "my_log_top") {
                document.getElementById("my_log_top").className = "log_class log_class_active";
                document.getElementById("company_log_top").className = "log_class";
            }else {
                document.getElementById("company_log_top").className = "log_class log_class_active";
                document.getElementById("my_log_top").className = "log_class";
            }
        }

        function page_zhanshi() {
            document.getElementById('page_one').style.display = 'inline-block';
        }

        function page_yincang() {
            document.getElementById('page_one').style.display = 'none';
        }

        const gridManagerName = "test",
        TYPE_MAP = {1: "HTML/CSS", 2: "nodeJS", 3: "javaScript", 4: "前端鸡汤", 5: "PM Coffee", 6: "前端框架", 7: "前端相关"},
        arg = {
            gridManagerName: "test",
            width: "100%",
            height: "100%",
            autoOrderConfig: {fixed: "left"},
            checkboxConfig: {key: "id", fixed: "left"},
            supportAjaxPage: !0,
            sortMode: "single",
            supportMenu: !0,
            menuHandler: e => (e.unshift({
                content: "自定义菜单", line: !0, onClick: e => {
                    alert(e)
                }
            }), e),
            useCellFocus: !0,
            useHideRow: !0,
            supportMoveRow: !0,
            moveRowConfig: {
                key: "priority", useSingleMode: !0, fixed: "left", handler: (e, t) => {
                    console.log(e, t)
                }
            },
            disableCache: !1,
            ajaxData: function (e, t) {
                return "/that-center/LogManagement.html"
            },
            exportConfig: {
                fileName: e => {
                    const t = new Date;
                    let a = `${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()}`;
                    for (let t in e) a = `${a}-${t}=${e[t]}`;
                    return a
                }, suffix: "xls"
            },
            ajaxType: "POST",
            checkedBefore: function (e, t, a) {
                return console.log("checkedBefore==", e, t, a), a && 90 === a.id && alert("该节点在checkedBefore中配置为不可选"), a && 90 !== a.id
            },
            responseHandler: e => (e.data.forEach((e => {
                e.priority = e.id
            })), e),
            rowRenderHandler: (e, t) => e,
            emptyTemplate: e => `<div style="text-align: center;">${e.query.title ? "搜索为空" : "暂无数据"}</div>`,
            columnData: [
                {
                    key: "log_date",
                    text: "日期",
                    align: "center",
                }, {
                    key: "company",
                    text: "科室",
                    align: "center",
                }, {
                    key: "proposed_department",
                    text: "提出科室",
                    align: "center",
                }, {
                    key: "content_problems",
                    text: "工作内容及问题描述",
                    align: "center",
                }, {
                    key: "suggestion_solution",
                    text: "建议说明及解决方法",
                    align: "center",
                }, {
                    key: "solution_situation",
                    text: "解诀情况",
                    align: "center",
                }, {
                    key: "settlement_date",
                    text: "预计解决日期",
                    align: "center",
                },{
                    key: "preparer",
                    text: "填表人",
                    align: "center",
                }, {
                    key: "remark",
                    text: "备注",
                    align: "center",
                },
                {
                    key: "action",
                    width: "100px",
                    align: "center",
                    fixed: "right",
                    disableMoveRow: !0,
                    disableRowCheck: !0,
                    text: '<span style="color: red">操作</span>',
                    template: (e, t) => `<a class="plugin-action" id="${t.id}" href="javascript:;">查看编辑</a>`
                }]
        }, demo1 = {
            initSearch: function () {
            }, initFN: () => {

            }, initGM: function () {
                new window.GridManager(table, arg, (e => {
                    console.log("渲染完成后的回调函数:", e), console.log(arg.columnData)
                }))
            }, editRowData: function (e) {
                window.GridManager.updateRowData("test", "id", {
                    id: window.parseInt(e.getAttribute("data-id")),
                    lastDate: (new Date).getTime()
                })
            }
        }, table = document.querySelector("#main_table");
        demo1.initSearch(table), demo1.initGM(table), demo1.initFN();

        function upload_excel(types) {
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            var files = document.getElementById("party_main_body").files[0];
            form.append('file', files);
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/that-center/UploadExcel", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        if (JsonDate['code'] === 200) {
                            alert("上传成功！")
                            location.reload()
                        }
                        document.getElementById("party_main_body").value = "";
                    }
                }
            };
        }
    </script>
{% endblock %}
